Before C++11, auto
was used as a storage class specifier that indicated automatic duration. Since that’s the default, the use of
auto
in that context was wholly redundant.
Because the keyword was redundant and therefore rarely used, C++11 repurposes it. auto
is now used to specify that the type of the
variable or function should be deduced from its context.
Since it is redundant under older standards and problematic under C++11, auto
's use as a storage-class identifier should be
removed.
Noncompliant code example
auto int x; // Noncompliant: redundant before C++11, error as of C++11
auto int y; // Noncompliant
Compliant solution
int x;
auto y = 1 + 2; // C++11: type of 'y' will be inferred